<?php

function print_archives($id_playlist, $name, $author, $genre1, $genre2, $genre3, $ambiance, $type_img, $date) {
    switch ($type_img) {
        case 0 :
            $ext = 'png';
            break;
        case 1 :
            $ext = 'jpg';
            break;
        default :
            $ext = '';
            break;
    }
    echo '<div id="archive_playlist">
    		
                <div id="abox1">
                <span id="archive_name">' . strtoupper ($name) . '</span>
                <span id="archive_author">par ' . $author . '</span>   
                </div>
                <img id="img_archive" src="' . URL_IMG . 'archives/' . $id_playlist . '.' . $ext . '" />';


    $bdd = model_db_connexion();
    $rex = model_archives_sons($bdd, $id_playlist);
    echo '<span id="archive_son_box">';
    while ($donnees = $rex->fetch(PDO::FETCH_ASSOC)) {
        
        echo '<span id="archive_son_title">';
        $title = $donnees['son_title'];
        $auteur  = $donnees['son_author'];
        echo $auteur .' - '. $title;
        echo '</span>';
        
    }
    echo '</span>';
    echo '<div id="abox2"><span id="archive_genre">';
    if ($genre1 == 1) {
        echo 'rock';
    } elseif ($genre1 == 2) {
        echo'disco';
    } elseif ($genre1 == 3) {
        echo'funk';
    }
    echo '/';
    if ($genre2 == 1) {
        echo 'rock';
    } elseif ($genre2 == 2) {
        echo'disco';
    } elseif ($genre2 == 3) {
        echo'funk';
    }
    echo '/';
    if ($genre3 == 1) {
        echo 'rock';
    } elseif ($genre3 == 2) {
        echo'disco';
    } elseif ($genre3 == 3) {
        echo'funk';
    }
    echo '</span>';
    echo ' <span id="archive_date">le ' . date("d/m/Y", strtotime($date)) . '</span></div>';
    echo '</div>';
}

?>
